import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const userName = 'user-name'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setlocalStorageKV(key, value) {
  localStorage.setItem(key, value)
}

export function getlocalStorageKV(key) {
  return localStorage.getItem(key)
}

export function getName() {
  return Cookies.get(userName)
}

export function setName(name) {
  return Cookies.set(userName, name)
}

export function removeName() {
  return Cookies.remove(userName)
}

//  给对象加token

export function addToken(params) {
  if (params) {
    params.token = getToken()
    if (!params.activeUrlId) {
      params.activeUrlId = '100000'
    }
  }
}
